package com.wzh.service;

import com.wzh.dao.NoteDao;
import com.wzh.pojo.Po.Notes;
import com.wzh.pojo.Po.UserZp;
import com.wzh.pojo.Req.DataReq;
import com.wzh.pojo.Resp.DataResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoteService {
	@Autowired
	private NoteDao noteDao;
	public  DataResp<Object> addnote(Notes notes) {
		DataResp<Object> resp=new DataResp<Object>();
		Integer result=noteDao.addnote(notes);

		if (result>0){
			resp.setMes("操作成功！");
		}else{
			resp.setMes("操作失败！");
		}
		return  resp;
	}

	public  DataResp<Object> findnotes(DataReq req) {
		DataResp<Object> resp=new DataResp<>();
		List<Notes> Listnotes= noteDao.findnotes(req);
		if (Listnotes.size()!=0){
			resp.setData(Listnotes);
			resp.setPageCount(req.getPageCount());
			resp.setMes("查询成功！");
		}else{
			resp.setMes("查询失败！");
		}
		return  resp;
	}

	public DataResp<Object> FindNoteByPhone(UserZp userZp) {
		DataResp<Object> resp=new DataResp<>();
		List<Notes> notes= noteDao.findNoteByPhone(userZp);
		if (notes.size()!=0){
			resp.setPageCount(notes.size());
			resp.setData(notes);
			resp.setMes("查询成功！");
		}else{
			resp.setMes("查询失败！");
			resp.setCode(205);//不存在简历数据
		}
		return  resp;

	}
}
